package org.droid.campusorder.adapter;

import org.droid.R;
import org.droid.campusorder.common.GlobalData;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CanteenAdapter extends BaseAdapter {

	LayoutInflater inflater;
	Context context;

	public CanteenAdapter(Context context) {
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return GlobalData.canteenBeanList == null?0:GlobalData.canteenBeanList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		inflater = LayoutInflater.from(context);
		convertView = inflater.inflate(R.layout.canteen_row, null);
		TextView tv_canteenlist_cname = (TextView) convertView.findViewById(R.id.tv_canteenlist_cname);
		TextView tv_canteenlist_cdesc = (TextView) convertView.findViewById(R.id.tv_canteenlist_cdesc);
		tv_canteenlist_cname.setText(GlobalData.canteenBeanList.get(position).getName().trim());
		tv_canteenlist_cdesc.setText(GlobalData.canteenBeanList.get(position).getDesc().trim());
		return convertView;
	}

}
